
<template>
  <el-dialog :visible.sync="visible" custom-class="dialog_big"
    :title="$tt('label_srm_insurance_insue_log_insurance_record')" v-loading="loading">

    <ex_super_desc v-bind="descOption" :data="form">
    </ex_super_desc>
    <ex_super_table v-bind="tableOption" :data="tableData" size="default">
    </ex_super_table>
  </el-dialog>
</template>

<script>
export default {
  components: {},
  route_manual: true,

  data() {
    return {
      visible: false,
      loading: false,
      form: {},
      tableData: [],
      descOption: {
        attrs: {
          size: "default", direction: "vertical", column: 4, border: true,
          labelClassName: 'widthdiv4', contentClassName: 'widthdiv4'
        },
        model: [
          { key: 'declareNo', label: 'label_srm_insurance_insue_log_declaration_no', },
          { key: 'insurancePlatform', label: 'label_srm_insurance_insue_log_insurance_platform', 'show-overflow-tooltip': true, },
          { key: 'insuranceCode', label: 'label_srm_insurance_insue_log_insurance_no', 'show-overflow-tooltip': true, },
          { key: 'policyNo', label: 'label_srm_platform_policy_no', },
          { key: 'apiServiceId', label: 'label_srm_insurance_insue_log_api_service_id', keyShow: 'expandDesc', },
          { key: 'customerCode', label: 'label_srm_api_request_customer_code', },
          { key: 'cargoWorth', label: 'label_srm_insurance_insue_log_cargo_value', },
          { key: 'premium', label: 'label_srm_platform_premium', },
          { key: 'insureNumber', label: 'label_srm_insurance_insue_log_insurance_count', },
          { key: 'insureStatus', label: 'label_srm_insurance_insue_log_insurance_status', 'width': 150, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
          { key: 'insureDate', label: 'label_srm_insurance_insue_log_success_insu_date', formatter: (r, c, v) => this.$dateFormat(v) },
          { key: 'stockinStatus', label: 'label_srm_insurance_insue_log_store_decl_status', 'width': 150, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
          { key: 'stockinDate', label: 'label_srm_insurance_insue_log_store_decl_date', formatter: (r, c, v) => this.$dateFormat(v) },
          { key: 'inventoryStatus', label: 'label_srm_insurance_insue_log_inv_decl_status', 'width': 150, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
          { key: 'inventoryDate', label: 'label_srm_insurance_insue_log_inv_last_date', formatter: (r, c, v) => this.$dateFormat(v) },
        ],
      },
      tableOption: [
        {

          model: [
            { key: 'tradeNo', label: 'label_fms_account_log_serial_number', },
            { key: 'inventoryNo', label: 'label_tms_inv_apply_number' },
            { key: 'insuranceType', label: 'label_tms_insurance_type', 'width': 150, formatter: (r, c, v, i) => this.$enumShow(v, "ApiInsuranceTypeEnum") },
            { key: 'success', label: 'label_srm_api_request_success', 'width': 150, formatter: (r, c, v, i) => this.$enumShow(v, "TrueOrFalseEnum") },
            { key: 'errorCode', label: 'label_srm_api_request_error_code', 'width': 150, 'show-overflow-tooltip': true, },
            {
              key: 'errorMsg', label: 'label_srm_api_request_error_message', 'width': 150,
              render: (h, { row, column }) => {
                const code = row[column.property]
                if (!code) return this.$tt('data_temp_none')
                return (<text_extra_tooltip_operate
                  value={code} ellipsis
                  data_type={column.property} data_id={row.id}
                />)
              },


            },
            {
              key: 'requiredParameter', label: 'label_srm_request_param', 'width': 150,
              render: (h, { row, column }) => {
                const code = row[column.property]
                if (!code) return this.$tt('data_temp_none')
                return (<text_extra_tooltip_operate
                  value={code} ellipsis
                  data_type={column.property} data_id={row.id}
                />)
              },

            },
            {
              key: 'responseMessage', label: 'label_srm_response_message', 'width': 150,
              render: (h, { row, column }) => {
                const code = row[column.property]
                if (!code) return this.$tt('data_temp_none')
                return (<text_extra_tooltip_operate
                  value={code} ellipsis
                  data_type={column.property} data_id={row.id}
                />)
              },
            },
          ],
        }
      ],
    }
  },
  methods: {
    show({ params, data }) {
      this.visible = true
      this.form = data

      this.loading = true
      this.$ajax({
        url: '/srm-api/supplier/ApiInsuranceOrderRpc/detail.json',
        method: 'post',
        data: params,
        success: (res) => {
          this.tableData = res.data.rows
        },
        complete: () => {
          this.loading = false
        }
      })
    },

    hide() {
      this.visible = false
    },
    copyTextToClipboard(message) {
      if (this.$tool.copyTextToClipboard(message)) {
        this.$message.success(this.$tt('label_has_copy'))
      }
    },
  }
}
</script>
